import { makeAutoObservable } from "mobx";
import { Store } from "./index";
export type ListType = {
  id: string;
  startTime: string;
  endTime: string;
  departureAirport: string;
  landingAirport: string;
  price: string;
  realPrice: number;
  flightName: string;
  priceDesc: string;
  tips?: string;
  seconds: number;
};

type OwnState = {
  list: ListType[];
  rowList: ListType[];
};

export class List {
  public state: OwnState = { list: [], rowList: [] };
  constructor() {
    makeAutoObservable(this);
  }
  setList(list: ListType[]) {
    this.state.list = list;
  }
  setRowList(list: ListType[]) {
    console.log("setRowList");

    this.state.rowList = list;
    this.state.list = list;
  }
  resetList() {
    this.state.list = this.state.rowList;
  }
}

export const getList = (store: Store) => store.list.state.list;
